home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 2
/
AACD 2.iso
/
AACD
/
Magazine
/
UsingPDF
/
ps2pdf
< prev
next >
Wrap
Text File
|
1999-10-02
|
4KB
|
133 lines
/*
Convert PostScript files to Portable Document Format using GhostScript
$VER: ps2pdf 1.0 (21.9.99) by Neil Bothwick
*/
/* ;;; Initialise */
call addlib('rexxsupport.library',0,-30,0)
options results
signal on error
VerStr = sourceline(3)
VerStr = subword(VerStr,2,words(VerStr) - 4)
WinTitle = 'Convert Postscript to PDF'
GuiPort = 'PS2PDF'
PrgPort = GuiPort'.1'
MUIA_Menuitem_Shortcut = 0x80422030
MUIM_Application_AboutMUI = 0x8042d21d
MUIM_Application_OpenConfigWindow = 0x804299ba
MUIA_Group_SameHeight = 0x8042037e
MUIA_Group_SameWidth = 0x8042b3ec
MUIA_Group_Spacing = 0x8042866d
MUIA_Group_Columns = 0x8042f416
MUIA_Group_Rows = 0x8042b68f
MUIA_Selected = 0x8042654b
MUIA_Disabled = 0x80423661
MUIA_Application_Author = 0x80424842
MUIA_Application_Copyright = 0x8042ef4d
MUIA_Application_Description = 0x80421fc6
MUIA_Application_Title = 0x804281b8
MUIA_Application_Version = 0x8042b33f
MUIA_Application_Sleep = 0x80425711
;;;
/* ;;; Create main window */
thisport = openport(PrgPort)
if thisport = 0 then exit
address(GuiPort)
window id MAIN port PrgPort command 'QUIT' title '"'WinTitle'"'
menu ID PROJM label 'Project'
item ID ABOUM port PrgPort command '"ABOUT"' ATTRS MUIA_Menuitem_Shortcut '"?"' label 'About'
item port GuiPort command '"method 'MUIM_Application_AboutMUI' 0"' label 'About MUI'
menu ID SETTM label 'Settings'
item port PrgPort command '"method 'MUIM_Application_OpenConfigWindow'"' label 'MUI...'
endmenu
item ID QUITM port PrgPort command 'QUIT' ATTRS MUIA_Menuitem_Shortcut 'Q' label 'Quit'
endmenu
group ATTRS MUIA_Group_Columns 2
label DOUBLE LEFT 'Input file'
popasl ID INF port PrgPort help '"The postscript file to convert"'
label DOUBLE LEFT 'Output file'
popasl ID OUTF port PrgPort help '"The PDF file you wish to create"'
space
endgroup
group HORIZ
button ID CONV port PrgPort command '"Convert"' help '"Start the conversion"' label 'Convert'
endgroup
endwindow
;;;
/* ;;; Check that GhostScript is installed correctly */
signal off error
address command 'Assign >NIL: GhostScript: EXISTS'
signal on error
if RC > 0 then do
call ShowMsg('You must install GhostScript first')
call Quit()
end
;;;
/* ;;; Main loop */
do forever
call waitpkt(PrgPort)
packet = getpkt(PrgPort)
if packet = '0000 0000'x then iterate
cmd = getarg(packet)
call reply(packet,0)
parse var cmd cmd args
interpret 'call 'cmd'("'args'")'
end
;;;
/* ;;; Do the conversion */
Convert:
'popasl ID INF'
InFile = result
if InFile = '' then do
call ShowMsg('You must supply the name of a file to convert')
return
end
'popasl ID OUTF'
OutFile = result
if OutFile = '' then OutFile = InFile'.pdf'
InDir = left(InFile,max(lastpos('/',InFile),lastpos(':',InFile)))
call Pragma('D',InDir)
'application' MUIA_Application_Sleep TRUE
address command 'GhostScript:gs >T:ps2pdf.tmp -q -dNOPAUSE -dBATCH -sPAPERSIZE=a4 -sDEVICE=pdfwrite -sOutputFile='OutFile InFile
'application' MUIA_Application_Sleep FALSE
if word(statef('T:ps2pdf.tmp'),2) = 0 then call ShowMsg('Conversion successful')
else do
call ShowMsg('Conversion failed')
address command 'AACDfile T:pdf2ps.tmp'
end
options failat 21
call delete('T:pdf2ps.tmp')
call Quit()
return
;;;
/* ;;; Show about requester */
About:
call ShowMsg(VerStr' by Neil Bothwick\n\nConvert Postscript files to PDF using GhostScript\n\n© 1999 by KornyBoth Productions Inc.\nThis product is Shareware\nShareware fee B&H20')
return
;;;
/* ;;; ShowMsg */
ShowMsg:
parse arg msg
'request id MAIN title "'WinTitle'" gadgets "OK" string' msg
return
;;;
/* ;;; Error handler */
Error:
address command 'requestchoice >NIL: "error" "Error' RC 'in line' sigl'" "OK"'
if RC = 5 then return
call ShowMsg('Error' RC 'in line' sigl)
call Quit()
return
;;;
/* ;;; Quit */
Quit:
address(GuiPort)
'QUIT'
exit
;;;